<?php
/**
 * a pagination class
 *
 * @author tom.wang<tom.wang.sz@qq.com>
 */
class Page {
	public static $cfg;
	
	public static function html($cfg = array()) {
		self::setCfg($cfg);
		//具体render类，这里是策略模式的应用
		$clzName = 'PageStyle' . self::$cfg['style'];
		$clzFile = FRAMEWORK_PAGE_ROOT . "drivers/{$clzName}.class.php";
		if(file_exists($clzFile)) require_once $clzFile;
		$style = new $clzName();
		return $style->html();
	}
	
	public static function render($cfg = array()) {
		echo self::html($cfg);
	}
	
	private static function setCfg($cfg) {
		self::$cfg = require FRAMEWORK_PAGE_ROOT . 'config.php';
		
		foreach($cfg as $key => $val) {
			if(array_key_exists($key, self::$cfg)) self::$cfg[$key] = $val;
		}
	}
}
?>